<template>
  <div>
    <button @click="comName = 'UserName'">账号密码填写</button>
    <button @click="comName = 'UserInfo'">个人信息填写</button>

    <p>下面显示注册组件:</p>
    <div style="border: 1px solid red">
      <!-- vue内置的组件component, 可以动态显示组件 -->
      <keep-alive include="UserName">
        <component :is="comName"></component>
      </keep-alive>
        
    </div>
  </div>
</template>

<script>
import UserName from "./components/UserName.vue";
import UserInfo from "./components/UserInfo.vue";
export default {
  data() {
    return {
      comName:'UserName'
    };
  },
  components: {
    UserName,
    UserInfo,
  },
};
</script>